<template>
  <view class="container">
    <uni-forms ref="form" :model="formData" :rules="rules">
      <uni-forms-item name="username">
        <uni-easyinput v-model="formData.username" placeholder="请输入用户名"></uni-easyinput>
      </uni-forms-item>
      <uni-forms-item name="password">
        <uni-easyinput type="password" v-model="formData.password" placeholder="请输入密码"></uni-easyinput>
      </uni-forms-item>
      <button @click="login">登录</button>
    </uni-forms>
  </view>
</template>

<script>
export default {
  data() {
    return {
      formData: {
        username: '',
        password: ''
      },
      rules: {
        username: {
          rules: [
            { required: true, message: '请输入用户名' }
          ]
        },
        password: {
          rules: [
            { required: true, message: '请输入密码' }
          ]
        }
      }
    };
  },
  methods: {
    login() {
      this.$refs.form.validate().then(res => {
        // uni.$u.api.uniIdLogin(this.formData).then(res => {
          
            uni.showToast({ title: '登录成功' });
            uni.switchTab({ url: '/pages/member/menber' });
        });
      // });
    }
  }
};
</script>